<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
    <!-- <script src="/javascripts/axios.min.js"></script> -->
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  </head>
  <body>
    <h1>喵喵交友-CMS管理系统</h1>
    <label for="">
      上传图片：<input type="file" id="uploadBtn">
    </label>
    <script>
      /* var uploadBtn = document.getElementById('uploadBtn');
      uploadBtn.onchange = function(ev){// onchange事件在确认上传文件后触发
        var file = ev.target.files[0];
        var param = new FormData();
        param.append('file', file);

        var config = {// 配置文件，告诉我们后端我们要接收的文件的一个二进制数据流。
          header: {
            // "Content-Type": "multipart/form-data"
            'Content-Type': 'multipart/form-data'
          }
        };

        axios.post('/uploadBannerImg', param, config).then(res=>{
          console.log(res.data);
        })
      } */

      var uploadBtn = document.getElementById('uploadBtn');
      uploadBtn.onchange = function(ev){
        var file = ev.target.files[0];
        var param = new FormData();
        param.append('file' , file);
       
        var config = {
          headers : {
            'Content-Type' : 'multipart/form-data'
          }
        };
  
        axios.post('/uploadBannerImg',param , config).then((res)=>{
  
        });
  
      };
    </script>
  </body>
</html>
